#pragma once
#include "def.h"

#define MAXLEN  255

enum{
    STRING = 0,
    DEC_NUMBER,
    HEX_NUMBER,
    OTHERS
};

enum{
    nothing = 0,
    enter = 1,
    bufok = 0xa0,
    empty ,
    full ,
    noinit,
};

typedef struct{
u8 data[MAXLEN];
u8 status;
u16 datalen;
u16 readlen;
u16 writelen;
}console_data;

extern console_data ConsoleRingbuf;

typedef struct
{
    char name[20];
    char desc[20];
    void (*func)(void);
}application_struct;

typedef void(*console_delay)(u32);
typedef int(*console_printf)(const char*, ...);

extern application_struct application_list[20];

void Tmier(void);
void Init_Console(console_delay p, console_printf pp);
u8 Get_ptrlen(char *data_ptr);
void InitRintbuf(console_data *ConsoleRingbuf);
u8 Add_char_toRingbuf(console_data *ConsoleRingbuf,u8 ch);
u8 Add_buf_toRingbuf(console_data *ConsoleRingbuf,const u8* ch,u16 len);
u8 Get_char_fromRingbuf(console_data *ConsoleRingbuf,u8* ch);
u8 Get_buf_fromRingbuf(console_data *ConsoleRingbuf,u8* ch,u16 len);
u8 Get_char_fromRingbuf_last(console_data *ConsoleRingbuf,u8* ch);
//u8 Check_Cammand(void);
void Console_main(void);
u8 Check_iput(void);
u8 Deal_keyboard(u8 data);
u8 Deal_ConsoleMian(void);
